<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>订单轨迹</title>
    <link href="/bootstrap/css/bootstrap.min.css" rel="stylesheet"></link>
    <script src="/js/layer/layer.js}"></script>
    <script src="/common/common.js}"></script>
    <script type="text/javascript" src="/jquery-3.3.1.min.js"></script>
    <script src="/bootstrap/js/bootstrap.min.js"></script>
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <input type="hidden" name="orderId" id="orderId" th:value="${orderId}" value="订单编号"/>
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <form action="#" method="post">
                    <div class="ibox-body">
                        <div class="form-group">
                            <label class="col-sm-3 control-label am-label-require"> 订单编号：</label>
                            <div class="col-sm-8">
                                <input id="order" class="form-control" type="text" readonly="readonly"  autocomplete="off" value=""/>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label am-label-require"> 商品名称：</label>
                            <div class="col-sm-8">
                                <input id="title" class="form-control" readonly="readonly"  type="text"  autocomplete="off" value=""/>
                            </div>
                        </div>
                        <div id="market" class="form-group" hidden="hidden">
                            <label class="col-sm-3 control-label am-label-require"> 活动名称：</label>
                            <div class="col-sm-8">
                                <input id="marketName" class="form-control" readonly="readonly"  type="text"  autocomplete="off" value=""/>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label am-label-require"> 客户：</label>
                            <div class="col-sm-8">
                                <input id="name" class="form-control" readonly="readonly" type="text" autocomplete="off" value=""/>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label am-label-require"> 下单时间：</label>
                            <div class="col-sm-8">
                                <input id="orderTime" class="form-control" readonly="readonly" type="text" autocomplete="off" value=""/>
                            </div>
                        </div>

                    </div>
                </form>
            </div>
        </div>
    </div>
    <br>
</div>
</body>

<script type="text/javascript">
    //定义全局商品信息数组
    jQuery(document).ready(function(){
        var orderId = $("#orderId").val();
        $.ajax({
            url: "/selectOrder?id="+orderId,
            type: "GET",
            cache: false,
            success: function (data) {
                if (data.status == "success") {
                    //获取成功的操作
                    orderBo=data.data;
                    reloadDom();
                } else {
                    alert("获取订单轨迹失败,原因为: "+data.data);
                }
            }
        })

        function reloadDom(){
            $("#order").val(orderBo.id);
            $("#title").val(orderBo.itemBo.title);
            if(orderBo.marketBo != null){
                $("#market").removeAttr("hidden");
                $("#marketName").val(orderBo.marketBo.marketName);
            }
            $("#name").val(orderBo.userInfoPo.name);
            if(orderBo.orderTime != null){
                var time=new Date(orderBo.orderTime);
                var month=1+time.getMonth();
                var orderTime=time.getFullYear();
                if(month<=9){
                    orderTime=orderTime+" - 0"+ month;
                }else{
                    orderTime=orderTime+" - "+ month;
                }
                if(time.getDate()<=9){
                    orderTime=orderTime+" - 0"+time.getDate();
                }else{
                    orderTime=orderTime+" - "+time.getDate();
                }
                if(time.getHours()<=9){
                    orderTime=orderTime+"  0"+time.getHours()+":";
                }else{
                    orderTime=orderTime+" "+time.getHours()+":";
                }
                if(time.getMinutes()<=9){
                    orderTime=orderTime+"0"+time.getMinutes();
                }else{
                    orderTime=orderTime+time.getMinutes();
                }
                if(time.getSeconds()<=9){
                    orderTime=orderTime+":0"+time.getSeconds();
                }else{
                    orderTime=orderTime+":"+time.getSeconds();
                }
                $("#orderTime").val(orderTime);
            }
        }
    })


</script>

</html>
